#ifndef MESH_H_
#define MESH_H_

#include <D3DX10.h>
#include <D3D10.h>

#include "geometry.h"
#include "objloader.h"
#include "material.h"
#include <vector>

class Mesh {
public:
	Mesh();
	~Mesh();

	bool InitialiseModels(ID3D10Device *device);
	void Cleanup();

	void Render(ID3D10Device *device);
	void
			SetShaderVars(D3DXMATRIX World, D3DXMATRIX View,
					D3DXMATRIX Projection);
private:
	// Shader fields
	ID3D10InputLayout *vertexLayout;
	ID3DX10Mesh *mesh;
	ID3D10Effect *effect;
	ID3D10EffectTechnique *effectTechnique;
	ID3D10EffectMatrixVariable *WorldVariable, *ProjectionVariable,
			*ViewVariable;
	ID3D10EffectShaderResourceVariable* pTextureRV;

	ID3D10EffectVectorVariable* pCameraPositionVariable;
	ID3D10EffectVectorVariable* pAmbientVariable;
	ID3D10EffectVectorVariable* pDiffuseVariable;
	ID3D10EffectVectorVariable* pSpecularVariable;
	ID3D10EffectScalarVariable* pSpecularPowerVariable;
	ID3D10EffectScalarVariable *isTexturedVariable;
	ID3D10EffectScalarVariable *illumVariable;

	ObjLoader *objloader;
	std::vector<ID3D10ShaderResourceView *> textures;
private:
	bool InitialiseGeometry(ID3D10Device *device);
	bool InitialiseShader(ID3D10Device *device);
	bool CreateInputLayout(ID3D10Device *device);
	bool LoadTextures(ID3D10Device *device);
	void ObtainShaderVars();
};

#endif
